#include "AudioMgr.h"
#include "AudioEngine.h"

using namespace experimental;


CAudioMgr::CAudioMgr()
{
}

CAudioMgr::~CAudioMgr()
{
}

bool CAudioMgr::init()
{
	if (!Node::init()){
		return false;
	}
	m_nCurMusicId = -1;
	return true;
}

void CAudioMgr::playAudio(string music, bool isLoop, float volume)
{
	int audioId = AudioEngine::play2d(music, isLoop, volume);
}



void CAudioMgr::playOneAudio(string music, float volume)
{
	if (m_nCurMusicId != -1)
		AudioEngine::stop(m_nCurMusicId);
	m_nCurMusicId = AudioEngine::play2d(music, false, volume);
	AudioEngine::setFinishCallback(m_nCurMusicId, [&](int, const std::string&){
		m_nCurMusicId = -1;
	});
}
